package com.ruoyi.stuclient.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.stuclient.domain.EwcClientControl;
import com.ruoyi.stuclient.domain.dto.SMSGetDto;
import com.ruoyi.stuclient.mapper.EwcClientControlMapper;
import com.ruoyi.stuclient.service.IEwcClientControlService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;


/**
 * 短信模板信息Service业务层处理
 *
 * @author zsp
 * @date 2025-05-01
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class EwcClientControlServiceImpl extends MPJBaseServiceImpl<EwcClientControlMapper, EwcClientControl> implements IEwcClientControlService {

    @Override
    public void controlValid(SMSGetDto smsGetDto) {
        EwcClientControl entity = new EwcClientControl();
        //1.查询控制信息
        EwcClientControl ewcClientControl = this.getOne(Wrappers.<EwcClientControl>lambdaQuery().eq(EwcClientControl::getClientNo, smsGetDto.getClientNo())
                .eq(EwcClientControl::getControlType, "smsLimitControl"));
        if(ewcClientControl == null){
            entity.setClientNo(smsGetDto.getClientNo());
            entity.setConsecutiveGetCount(0);
            entity.setControlType("smsLimitControl");
            Date currentDate = new Date();
            entity.setCreateTime(currentDate);
            entity.setUpdateTime(currentDate);
            this.save(entity);
        }else{

        }

    }
}
